<?php
class Customer extends Vnf_Db_Table{
    protected $_name;
    protected $_primary = 'CustomerNo';

    function __construct() {
        $this->_name = DB_PREFIX . "customer";
        parent::__construct();
    }
    
     public function getColumns() {
        //$results = array('category_id', 'admin_title', 'parent', 'left', 'right', 'status');
        $results = array('CustomerNo', 'LastName', 'FirstName', 'Company', 'Street', 'Street2', 'City', 'State', 'Zip', 'Country', 'Phone', 'Phone2', 'Phone3', 'Fax', 'Fax2', 'Pager', 'Email','Email2', 'Resale', 'AuthAllowed', 'Notify', 'Since', 'ExtText1', 'ExtText2', 'ExtText3', 'ExtText4', 'ExtText5', 'ExtText6', 'ExtText7', 'ExtText8	', 'GroupName', 'Password', 'status', 'activecode', 'about_us');
        return $results;
    }

    public function getPrimaryKey() {
        $pk = $this->_primary;
        if (is_array($pk)) {
            if (count($pk) > 0)
                return $pk[1]; // array[1] contain column name of primary key
        }
        return $this->_primary;
    }
    
    public function getRecords($where = null, $order = null, $count = null, $offset = 0) {
        $table_name = $this->_name;
        $primary_key = $this->getPrimaryKey();
        $select = Zend_Db_Table_Abstract::select();
        $select->setIntegrityCheck(false)
            ->from(array('thistable' => $table_name))
           ;
        if($where) {
            $select->where($where);
        }
        if($order) {
            $select->order($order);
        }
        if($count)
            $select->limit($count, $offset);
        $data = $this->fetchAll($select);
        return $data;
    }
}
?>
